home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-10-04 | 1.6 KB | 58 lines | [TEXT/MPS ] |
- program TestRandomNumbers (input, output);
-
- { This program tests the random number generator implemented
- by the unit RandomNumbers. If the generator is the "minimal
- standard generator" (multiplicative linear congruential
- algorithm with modulus 2147483647 and multiplier 16807, and
- the initial seed is 1, the value of the seed after 10000
- iterations should be 1043618065. If this value is not
- obtained, then the generator either is not a "minimal
- standard" generator, or has failed due to integer overflow
- at some point.
-
- Under the Macintosh Programmer's Workshop, this program can
- be compiled and run as an MPW Tool. Under other systems,
- it may need some modification.
-
- This program was written in MPW Pascal v 3.2.
-
- Jon Bell
- Dept. of Physics & Computer Science
- Presbyterian College
- Clinton SC 29325
- CompuServe: #70441,353
- October 1991 }
-
-
- Uses RandomNumbers, Events;
-
- var
- k : longint;
- x : extended;
- stopTime : longint;
-
- begin
- InitRandomSeed (1);
- writeln;
- writeln ('The first ten random numbers are:');
- writeln;
- for k := 1 to 10 do
- writeln (RandomReal:20:18);
- for k := 11 to 10000 do
- x := RandomReal;
- writeln;
- writeln ('After 10000 iterations,');
- writeln ('the random seed is ', RandomSeed:1, '.');
- writeln;
- k := 0;
- stopTime := TickCount + 3600;
- while TickCount <= stopTime do
- begin
- x := RandomReal;
- k := k + 1
- end;
- writeln ('In one second, ', trunc(k/60):1,
- ' random numbers were generated.');
- writeln
- end.
-